package com.tengchong.ohos.slice;

import com.tengchong.ohos.CircleLoadingView;
import com.tengchong.ohos.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Slider;

public class MainAbilitySlice extends AbilitySlice {

    /**
     * 生命周期回调函数
     * @param intent
     */
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        //1、java代码设置背景图和进度
        //2、还可以通过xml设置
        CircleLoadingView circleLoadingView = (CircleLoadingView) findComponentById(ResourceTable.Id_main_cl);
        //circleLoadingView.setImageBitmap(circleLoadingView.getPixelMap(ResourceTable.Media_icon));
        //circleLoadingView.setPercent(66);
        Slider pb = (Slider) findComponentById(ResourceTable.Id_main_slider);
        pb.setValueChangedListener(new Slider.ValueChangedListener() {
            @Override
            public void onProgressUpdated(Slider slider, int i, boolean b) {
                circleLoadingView.setPercent(i);
            }

            @Override
            public void onTouchStart(Slider slider) {

            }

            @Override
            public void onTouchEnd(Slider slider) {

            }
        });
    }
}
